package com.kehutong.house.dao;

import com.kehutong.house.entity.House;
import org.coraframework.orm.annotation.Dao;
import org.coraframework.orm.annotation.Mapper;
import org.coraframework.orm.jdbc.Page;
import org.coraframework.orm.jdbc.execute.Condition;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Dao
public interface HouseDao {

	@Mapper(
			genericType = HashMap.class,
			countSQL ="select count(1) from t_house h LEFT JOIN t_community_building b ON b.id = h.buildNo AND h.deleted = false where ${}",
			sql="select h.id, h.communityNo," +
					"h.communityName," +
					"h.buildNo," +
					"h.buildName," +
					"h.unitName," +
					"h.floorName," +
					"h.name," +
					"h.viewName," +
					"h.mergeName," +
					"h.family," +
					"h.propertyType," +
					"h.buildArea," +
					"h.enable," +
					"h.useArea," +
					"h.payArea," +
					"h.ownerNo," +
					"h.ownerName," +
					"h.ownerMobile," +
					"h.salesStatus," +
					"h.harvestStatus," +
					"h.decoratedStasus," +
					"h.resideStasus," +
					"h.rentStasus," +
					"h.deleted," +
					"b.employeeNos from t_house h LEFT JOIN t_community_building b ON b.id = h.buildNo AND h.deleted = false where ${}"
	)
	public Page<Map<String, Object>> loadPage(Condition...condition);


	@Mapper(
			genericType = HashMap.class,
			sql="select h.id, h.communityNo," +
					"h.communityName," +
					"h.buildNo," +
					"h.buildName," +
					"h.unitName," +
					"h.floorName," +
					"h.name," +
					"h.viewName," +
					"h.mergeName," +
					"h.family," +
					"h.propertyType," +
					"h.buildArea," +
					"h.useArea," +
					"h.payArea," +
					"h.enable," +
					"h.ownerNo," +
					"h.ownerName," +
					"h.ownerMobile," +
					"h.salesStatus," +
					"h.harvestStatus," +
					"h.decoratedStasus," +
					"h.resideStasus," +
					"h.rentStasus," +
					"h.deleted," +
					"b.employeeNos from t_house h LEFT JOIN t_community_building b ON b.id = h.buildNo AND h.deleted = false where ${}"
	)
	public List<Map<String, Object>> loadlist(Condition...condition);


	@Mapper(
			genericType = House.class,
			sql="SELECT * FROM `t_house` WHERE ${}"
	)
	List<House> getHouseIdListByMultipleQuery(Condition...condition);
}
